package com.antis.olsl.data.stock.detail;

import com.alibaba.android.arouter.facade.annotation.Autowired;
import com.alibaba.android.arouter.facade.annotation.Route;
import com.alibaba.android.arouter.launcher.ARouter;
import com.antis.olsl.arouterlib.DataRoutePath;
import com.antis.olsl.base.BaseActivity;
import com.antis.olsl.data.databinding.ActivityCategoryDetailBinding;
import com.antis.olsl.data.response.GetCategoryInventoryDetailResp;
import com.trello.rxlifecycle2.LifecycleTransformer;

import java.util.HashMap;
import java.util.Map;

@Route(path = DataRoutePath.ACTIVITY_CATEGORY_DETAIL)
public class CategoryDetailActivity extends BaseActivity<ActivityCategoryDetailBinding> implements CategoryDetailContract.View {
    @Autowired
    String categoryName;

    private CategoryDetailPresenter mPresenter;

    @Override
    protected ActivityCategoryDetailBinding getViewBinding() {
        return ActivityCategoryDetailBinding.inflate(getLayoutInflater(), baseBinding.getRoot(), true);
    }

    @Override
    protected void initPresenter() {
        super.initPresenter();
        mPresenter = new CategoryDetailPresenter();
        mPresenter.takeView(this);
    }

    @Override
    protected void initViews() {
        ARouter.getInstance().inject(this);
    }

    @Override
    protected void initData() throws IllegalAccessException {
        Map<String, Object> map = new HashMap<>();
        map.put("categoryName", categoryName);
        mPresenter.getCategoryInventoryDetail(map);
    }

    @Override
    protected void onDestroy() {
        super.onDestroy();
        if (null != mPresenter) {
            mPresenter.unSubscribe();
        }
    }

    @Override
    public void getCategoryInventoryDetailSuccess(GetCategoryInventoryDetailResp.ContentBean bean) {

    }

    @Override
    public void getCategoryInventoryDetailFailure(String msg) {

    }

    @Override
    public boolean isActive() {
        return false;
    }

    @Override
    public <T> LifecycleTransformer<T> bindToLife() {
        return this.bindToLifecycle();
    }
}